#ifndef IBUFFERPROXY_H
#define IBUFFERPROXY_H

#pragma once

#include <IBuffer/IBuffer.h>

#include <LDF/LargeDisplayFrameworkLayer.h>

class VisComponent;

/**
 * This class is a proxy for the IBuffer class. It allows making abstract
 * references to an i-buffer without knowing the actual buffer data type. It
 * also associates a type identifier with the buffer instance, so that the
 * buffers of the same type can be treated consistently. The ID of this proxy
 * should be the same as the associated i-buffer's. The VisComponent object
 * that defines this buffer as one of its active buffers is considered the
 * owner of the buffer. The owner of the buffer should be used when converting
 * global to buffer coordinates.
 *
 * @author Fabricio Anastacio - fabriciocfa@yahoo.com
 * @since July 13, 2007
 */
class LARGEDISPLAYFRAMEWORKLAYER_API IBufferProxy
{
	// Attributes
private:
	/** A reference to the i-buffer object. */
	void* iBuffer;
	/** The identifier of this proxy and of the associated i-buffer. */
	unsigned int id;
	/** The type of the associate buffer. If no type is defined, it is zero. */
	unsigned int type;
	/** The component that has this buffer as active. */
	VisComponent* owner;


	// Methods
public:
	/**
	 * Constructs a default empty i-buffer proxy object.
	 */
	IBufferProxy(void);
	/**
	 * Destroys this object.
	 */
	~IBufferProxy(void);

	/**
	 * Returns the amount of memory allocated by this i-buffer in KyloBytes.
	 *
	 * @return the amount of memory allocated by this i-buffer in KyloBytes.
	 */
	unsigned long getAllocatedMemorySizeKBytes();

	// ACCESSOR METHODS
	/**
	 * Returns the reference to the associated i-buffer.
	 *
	 * @return the reference to the associated i-buffer.
	 */
	inline void* getBuffer() { return iBuffer; };
	/**
	 * Sets the reference to the associated i-buffer.
	 *
	 * @param buffer the reference to be set for the associated i-buffer.
	 */
	inline void setBuffer(void* buffer) { iBuffer = buffer; };
	/**
	 * Returns the identifier of this proxy and of the associated i-buffer.
	 *
	 * @return the identifier of this proxy and of the associated i-buffer.
	 */
	inline unsigned int getId() { return id; };
	/**
	 * Sets the identifier of this proxy and of the associated i-buffer.
	 *
	 * @param aId the identifier of this proxy and of the associated i-buffer.
	 */
	inline void setId(unsigned int aId) { id = aId; };
	/**
	 * Returns the type of the associated i-buffer.
	 *
	 * @return the type of the associated i-buffer.
	 */
	inline unsigned int getType() { return type; };
	/**
	 * Sets the type of the associated i-buffer.
	 *
	 * @param t the type to be set to the associated i-buffer.
	 */
	inline void setType(unsigned int t) { type = t; };
	/**
	 * Returns the component that owns (has as active) this buffer.
	 *
	 * @return the component that owns (has as active) this buffer.
	 */
	inline VisComponent* getOwner() { return owner; };
	/**
	 * Sets the owner of the associated i-buffer.
	 *
	 * @param component the component to be set as the owner of the associated
	 * i-buffer.
	 */
	inline void setOwner(VisComponent* component) { owner = component; };
};

#endif // IBUFFERPROXY_H
